home *** CD-ROM | disk | FTP | other *** search
/ Star Trek Starfleet Academy Mini Omnipedia / MINI_OMNI.ISO / pc / omni_v2.dxr / 00389_Scroll Manager.ls < prev    next >
Encoding:
Text File  |  1996-04-15  |  12.3 KB  |  441 lines

  1. property iScrollBackFlag, iScrollSpacerK, iPiconMaskTopK, iDescTextAreaHtK, iFldF1Num, iFldF2Num, iFldF3Num, iFldF4Num, iHopTxtList, iDescFldStartK, iHopCastHghtList, iHopItemsList, iChroMaxItems, iLastScrollDir, iDescFldTestK, iBottweak, iMyHeight, iDescTxtAreaMidK, iPrevCenter, iTheCenterSpr
  2. global oTextSlider, gCHROisScrolling, oIndexMediator, gscrtxtspr1, gScrollIncrK, gdescfield, gStyleCountThreshold, gModeState, gHopCounter, gGlobalStepCount, gTxtScrSprsBeg, gImInHelp, gPreStyledFlag, gStylePermitF, gPhotoSND, gPiconGarage, gPiconcastloc, gNumofpicons, gTopicIsText
  3.  
  4. on birth me
  5.   return me
  6. end
  7.  
  8. on mInitScrollStuff me
  9.   set iDescFldStartK to 190
  10.   set iDescFldTestK to 180
  11.   if the castNum of sprite 36 <> the number of cast "Picon Mask" then
  12.   end if
  13.   set iBottweak to 20
  14.   set iLastScrollDir to 1
  15.   set iScrollSpacerK to 5
  16.   set iPiconMaskTopK to the top of sprite 36
  17.   set iDescTextAreaHtK to iPiconMaskTopK - iDescFldStartK
  18.   set iDescTxtAreaMidK to (iDescTextAreaHtK / 2) + iDescFldStartK
  19.   set iFldF1Num to the number of cast "F1"
  20.   set iFldF2Num to the number of cast "F2"
  21.   set iFldF3Num to the number of cast "F3"
  22.   set iFldF4Num to the number of cast "F4"
  23.   set gPiconGarage to [:]
  24.   set iPrevCenter to 0
  25.   set iTheCenterSpr to 5
  26.   mResetHoppers(me)
  27.   mInitScrPupps(me)
  28.   mFlushTextHoppers(me)
  29.   set iChroMaxItems to mGetAnyMaxEntryNum(oIndexMediator, #CHRO)
  30.   mHomeTxtScroll(me)
  31.   set gHopCounter to 1
  32.   set gScrollIncrK to 14
  33. end
  34.  
  35. on mResetHoppers me
  36.   set gHopCounter to 1
  37.   set iHopTxtList to [5: iFldF1Num, 4: iFldF2Num, 3: iFldF3Num, 2: iFldF4Num]
  38.   repeat with i = 1 to 4
  39.     hPrepStyles(getAt(iHopTxtList, i))
  40.   end repeat
  41.   set iHopCastHghtList to [:]
  42.   addProp(iHopCastHghtList, iFldF1Num, getAt(the rect of cast iFldF1Num, 4))
  43.   addProp(iHopCastHghtList, iFldF2Num, getAt(the rect of cast iFldF2Num, 4))
  44.   addProp(iHopCastHghtList, iFldF3Num, getAt(the rect of cast iFldF3Num, 4))
  45.   addProp(iHopCastHghtList, iFldF4Num, getAt(the rect of cast iFldF4Num, 4))
  46.   set iHopItemsList to [:]
  47.   addProp(iHopItemsList, iFldF1Num, 0)
  48.   addProp(iHopItemsList, iFldF2Num, 0)
  49.   addProp(iHopItemsList, iFldF3Num, 0)
  50.   addProp(iHopItemsList, iFldF4Num, 0)
  51.   sort(iHopItemsList)
  52.   set gdescfield to getAt(iHopTxtList, gHopCounter)
  53. end
  54.  
  55. on mFlushTextHoppers me
  56.   repeat with i = 1 to 4
  57.     set the text of cast getAt(iHopTxtList, i) to " "
  58.   end repeat
  59. end
  60.  
  61. on mStoreMyInfo me, thecstnum
  62.   setaProp(iHopCastHghtList, thecstnum, getAt(the rect of cast thecstnum, 4))
  63.   setaProp(iHopItemsList, thecstnum, gGlobalStepCount)
  64. end
  65.  
  66. on mAdjustTopHopper me
  67.   if iScrollBackFlag then
  68.     set LnextLoc to the locV of sprite getPropAt(iHopTxtList, 2)
  69.     set LmyCstnum to getAt(iHopTxtList, 1)
  70.     set LmyHeight to getaProp(iHopCastHghtList, LmyCstnum)
  71.     set the locV of sprite getPropAt(iHopTxtList, 1) to LnextLoc - LmyHeight
  72.     set iScrollBackFlag to 0
  73.   end if
  74. end
  75.  
  76. on mGetMyBottLoc me, thecstnum
  77.   set Lthespr to getPropAt(iHopTxtList, getPos(iHopTxtList, thecstnum))
  78.   return the locV of sprite Lthespr + getProp(iHopCastHghtList, thecstnum)
  79. end
  80.  
  81. on mIsOffScreenUp me, pIndx
  82.   set Lthespr to getPropAt(iHopTxtList, pIndx)
  83.   if mGetMyBottLoc(me, getAt(iHopTxtList, pIndx)) < iDescFldStartK then
  84.     return 1
  85.   else
  86.     return 0
  87.   end if
  88. end
  89.  
  90. on mScanBottoms me
  91.   set Lme to 0
  92.   repeat with k = 1 to 4
  93.     if mIsPastBottLimit(me, k) then
  94.       set Lme to k
  95.       exit repeat
  96.     end if
  97.   end repeat
  98.   return Lme
  99. end
  100.  
  101. on mChroPicDispTest me, pReset
  102.   if pReset then
  103.     set iTheCenterSpr to 5
  104.     set iPrevCenter to iTheCenterSpr
  105.     set x to 1
  106.   else
  107.     repeat with i = 1 to 4
  108.       set Lspr to getPropAt(iHopTxtList, i)
  109.       if the locV of sprite Lspr < iDescTxtAreaMidK then
  110.         if the locV of sprite Lspr > iDescFldTestK then
  111.           set iTheCenterSpr to Lspr
  112.           exit repeat
  113.           next repeat
  114.         end if
  115.         set Lbottloc to mGetMyBottLoc(me, getAt(iHopTxtList, i))
  116.         if Lbottloc > iDescTxtAreaMidK then
  117.           set iTheCenterSpr to Lspr
  118.           exit repeat
  119.         end if
  120.       end if
  121.     end repeat
  122.     if iTheCenterSpr <> iPrevCenter then
  123.       set iPrevCenter to iTheCenterSpr
  124.       set x to 1
  125.     else
  126.       set x to 0
  127.     end if
  128.   end if
  129.   if x then
  130.     set Lcst to getaProp(iHopTxtList, iTheCenterSpr)
  131.     set Lnum to getaProp(iHopItemsList, Lcst)
  132.     mQueuePicons(me, Lnum)
  133.     mUpdateWinToCHROEntry(oIndexScroller, Lnum, 0)
  134.   end if
  135. end
  136.  
  137. on mIsPastBottLimit me, pIndx
  138.   if mGetMyBottLoc(me, getAt(iHopTxtList, pIndx)) < iPiconMaskTopK then
  139.     return 1
  140.   else
  141.     return 0
  142.   end if
  143. end
  144.  
  145. on mIsBelowTopLimit me, pIndx
  146.   if the locV of sprite getPropAt(iHopTxtList, pIndx) > (iDescFldStartK + gScrollIncrK) then
  147.     return 1
  148.   else
  149.     return 0
  150.   end if
  151. end
  152.  
  153. on mInitScrPupps me
  154.   repeat with i = 1 to 4
  155.     puppetSprite(getPropAt(iHopTxtList, i), 1)
  156.   end repeat
  157. end
  158.  
  159. on mHomeTxtScroll me
  160.   mPrepHopscotch(me)
  161.   set gdescfield to getAt(iHopTxtList, 1)
  162.   set the castNum of sprite getPropAt(iHopTxtList, 1) to gdescfield
  163.   set gscrtxtspr1 to getPropAt(iHopTxtList, 1)
  164.   updateStage()
  165. end
  166.  
  167. on mHomeScrollFields me
  168.   if (gModeState = #ENCY) or (gModeState = #EPIS) or (gModeState = #FoundSet) or (gModeState = #EPISSUB) or (gTopicIsText and (gModeState = #TOPICS)) then
  169.     puppetSprite(gscrtxtspr1, 1)
  170.     set the locV of sprite gscrtxtspr1 to iDescFldStartK
  171.     updateStage()
  172.     mSetSlider(oTextSlider, the locV of sprite gscrtxtspr1 - iDescFldStartK, 0)
  173.   else
  174.     if gModeState = #CHRO then
  175.     end if
  176.   end if
  177. end
  178.  
  179. on mNeedTheScrollBars me, pHt
  180.   if gModeState = #CHRO then
  181.     return 1
  182.   end if
  183.   if pHt > iDescTextAreaHtK then
  184.     return 1
  185.   else
  186.     return 0
  187.   end if
  188. end
  189.  
  190. on mScrollAtLimit me, pDir, ptheLoc, pMyHeight, pTweak
  191.   if pDir < 0 then
  192.     if ptheLoc > iDescFldStartK then
  193.       set the locV of sprite gscrtxtspr1 to iDescFldStartK
  194.       return 1
  195.     else
  196.       return 0
  197.     end if
  198.   else
  199.     set LbotLoc to ptheLoc + pMyHeight
  200.     if LbotLoc < (iDescFldStartK + pTweak) then
  201.       return 1
  202.     else
  203.       return 0
  204.     end if
  205.   end if
  206. end
  207.  
  208. on mPrepScrollStats me
  209.   set L1 to gTxtScrSprsBeg
  210.   set Ln to gTxtScrSprsBeg + 3
  211.   set iMyHeight to the height of cast gdescfield + 20
  212.   if mNeedTheScrollBars(me, iMyHeight) then
  213.     repeat with n = L1 to Ln
  214.       set the visible of sprite n to 1
  215.     end repeat
  216.     set vNewHeight to (iMyHeight - 214) / gScrollIncrK
  217.     if (vNewHeight > 0) and not (gModeState = #CHRO) then
  218.       mReDefineSlider(oTextSlider, 0, vNewHeight, 0)
  219.     end if
  220.   else
  221.     repeat with n = L1 to Ln
  222.       set the visible of sprite n to 0
  223.     end repeat
  224.   end if
  225. end
  226.  
  227. on mScrollMe me, pDir
  228.   mScrollHoppers(me, pDir)
  229.   repeat while the mouseDown
  230.     mScrollHoppers(me, pDir)
  231.   end repeat
  232.   mChroPicDispTest(me)
  233. end
  234.  
  235. on mScrollBarTextScroll me, pScrollUpDist
  236.   if (gModeState <> #CHRO) or gImInHelp then
  237.     set the locV of sprite gscrtxtspr1 to iDescFldStartK - (pScrollUpDist * gScrollIncrK)
  238.     if pScrollUpDist > 0 then
  239.       set gStyleCountThreshold to gStyleCountThreshold + (20 * pScrollUpDist)
  240.       hSetStylingNeed(1)
  241.     end if
  242.   end if
  243. end
  244.  
  245. on mTextSliderPage me, pStyle
  246.   if pStyle = #page then
  247.     set vshift to 13
  248.   else
  249.     set vshift to 1
  250.   end if
  251.   mSliderBarPage(oTextSlider, vshift)
  252. end
  253.  
  254. on mPrepHopscotch me
  255.   mResetHoppers(me)
  256.   set the locV of sprite getPropAt(iHopTxtList, 1) to iDescFldStartK
  257.   updateStage()
  258.   repeat with i = 2 to 4
  259.     set the locV of sprite getPropAt(iHopTxtList, i) to mGetMyBottLoc(me, getAt(iHopTxtList, i - 1)) + iScrollSpacerK
  260.     updateStage()
  261.   end repeat
  262. end
  263.  
  264. on mQueuePicons me, pNum
  265.   if voidp(getLast(gPiconGarage)) then
  266.     return 
  267.   end if
  268.   set Lwhere to findPos(gPiconGarage, pNum)
  269.   if voidp(Lwhere) then
  270.     return 
  271.   end if
  272.   set gPiconcastloc to getAt(gPiconGarage, Lwhere)
  273.   set gNumofpicons to count(gPiconcastloc)
  274.   deleteAt(gPiconGarage, Lwhere)
  275.   hPurgeMediaCHRO()
  276.   if gNumofpicons > 0 then
  277.     hDisplayPicons()
  278.   end if
  279. end
  280.  
  281. on mScrollHoppers me, pDir
  282.   set iLastScrollDir to pDir
  283.   set LmyFirstSpr to getPropAt(iHopTxtList, 1)
  284.   set the locV of sprite LmyFirstSpr to the locV of sprite LmyFirstSpr - (pDir * gScrollIncrK)
  285.   repeat with i = 2 to 4
  286.     set LmySpr to getPropAt(iHopTxtList, i)
  287.     set LmyCast to getAt(iHopTxtList, i - 1)
  288.     set the locV of sprite LmySpr to mGetMyBottLoc(me, LmyCast) + iScrollSpacerK
  289.   end repeat
  290.   updateStage()
  291.   set gCHROisScrolling to 1
  292.   if pDir > 0 then
  293.     if mGetMyBottLoc(me, getAt(iHopTxtList, gHopCounter)) < (iPiconMaskTopK - iScrollSpacerK) then
  294.       mSetNextHopper(me)
  295.       mGetAnuthrChronChunk(me, 0, pDir)
  296.     end if
  297.     if mGetMyBottLoc(me, getAt(iHopTxtList, 1)) < iDescFldStartK then
  298.       mPopToptoBott(me)
  299.     end if
  300.   else
  301.     if mIsBelowTopLimit(me, 1) then
  302.       mPopBotttoTop(me)
  303.       mSetNextHopper(me)
  304.       set Lcstnum to getAt(iHopTxtList, gHopCounter + 1)
  305.       set Lwhichprevone to getaProp(iHopItemsList, Lcstnum) - 1
  306.       mGetAnuthrChronChunk(me, Lwhichprevone, pDir)
  307.     end if
  308.   end if
  309.   set gCHROisScrolling to 0
  310. end
  311.  
  312. on mGetAnuthrChronChunk me, pWhich, pDir
  313.   hReportStatus("Acquiring additional text...")
  314.   if pDir > 0 then
  315.     hPlaceEntryRequest(1)
  316.     if gHopCounter > 1 then
  317.       set the locV of sprite getPropAt(iHopTxtList, gHopCounter) to mGetMyBottLoc(me, getAt(iHopTxtList, gHopCounter - 1)) + iScrollSpacerK
  318.     end if
  319.   else
  320.     set Loffset to (gGlobalStepCount - pWhich) * -1
  321.     hPlaceEntryRequest(Loffset)
  322.   end if
  323. end
  324.  
  325. on mWaitForStyling me
  326.   set gStylePermitF to 1
  327.   repeat while hStyleMe() = 0
  328.   end repeat
  329. end
  330.  
  331. on mSetNextHopper me
  332.   if gHopCounter < 4 then
  333.     set gHopCounter to gHopCounter + 1
  334.   end if
  335.   set gdescfield to getAt(iHopTxtList, gHopCounter)
  336.   if gHopCounter > 1 then
  337.     set the locV of sprite getPropAt(iHopTxtList, gHopCounter) to mGetMyBottLoc(me, getAt(iHopTxtList, gHopCounter - 1)) + iScrollSpacerK
  338.   end if
  339. end
  340.  
  341. on mTextUpdateCheck me
  342.   global gYouClickedF
  343.   if gYouClickedF then
  344.     set gYouClickedF to 0
  345.     return 
  346.   end if
  347.   if mIsBelowTopLimit(me, gHopCounter) and (iLastScrollDir < 0) then
  348.     return 
  349.   end if
  350.   if mIsPastBottLimit(me, gHopCounter) and (iLastScrollDir > 0) then
  351.     mWaitForStyling(me)
  352.     mSetNextHopper(me)
  353.     if gHopCounter = 1 then
  354.       exit
  355.     end if
  356.     hSysAlert(#null)
  357.     hWinVoiceMicOff()
  358.     set gCHROisScrolling to 1
  359.     set Mycstnum to getAt(iHopTxtList, gHopCounter - 1)
  360.     set Lwhichnextone to getaProp(iHopItemsList, Mycstnum) + 1
  361.     mGetAnuthrChronChunk(me, Lwhichnextone, 1)
  362.     set gCHROisScrolling to 0
  363.     return 
  364.   end if
  365. end
  366.  
  367. on mClearThisHopper me, x
  368.   set Lmyfld to getAt(iHopTxtList, value(x))
  369.   hPrepStyles(Lmyfld)
  370.   setaProp(iHopItemsList, Lmyfld, 0)
  371. end
  372.  
  373. on mPopToptoBott me
  374.   set Ltemp to [:]
  375.   set L1 to getPropAt(iHopTxtList, 1)
  376.   set L2 to getAt(iHopTxtList, 1)
  377.   deleteAt(iHopTxtList, 1)
  378.   addProp(iHopTxtList, L1, L2)
  379.   if gHopCounter > 1 then
  380.     set gHopCounter to gHopCounter - 1
  381.   end if
  382.   mClearThisHopper(me, 4)
  383.   updateStage()
  384. end
  385.  
  386. on mPopBotttoTop me
  387.   set LP1 to getPropAt(iHopTxtList, 4)
  388.   set LV1 to getAt(iHopTxtList, 4)
  389.   set LP4 to getPropAt(iHopTxtList, 3)
  390.   set LV4 to getAt(iHopTxtList, 3)
  391.   set LP3 to getPropAt(iHopTxtList, 2)
  392.   set LV3 to getAt(iHopTxtList, 2)
  393.   set LP2 to getPropAt(iHopTxtList, 1)
  394.   set LV2 to getAt(iHopTxtList, 1)
  395.   set iHopTxtList to [:]
  396.   addProp(iHopTxtList, LP1, LV1)
  397.   addProp(iHopTxtList, LP2, LV2)
  398.   addProp(iHopTxtList, LP3, LV3)
  399.   addProp(iHopTxtList, LP4, LV4)
  400.   set gHopCounter to 0
  401.   mClearThisHopper(me, 1)
  402.   set iScrollBackFlag to 1
  403.   updateStage()
  404. end
  405.  
  406. on mhopreport me
  407.   put "iHopTxtList..." & iHopTxtList
  408.   put "#:Fld:Spr:Top:Text"
  409.   repeat with i = 1 to 4
  410.     set thefld to getAt(iHopTxtList, i)
  411.     set thespr to getPropAt(iHopTxtList, i)
  412.     put i && "  " & thefld && "  " & thespr && "  " & the top of sprite thespr && "  " & char 1 to 4 of field thefld
  413.   end repeat
  414.   put "iHopCastHghtList..."
  415.   repeat with j = 1 to 4
  416.     put getPropAt(iHopCastHghtList, j) && getAt(iHopCastHghtList, j)
  417.   end repeat
  418.   put "iHopItemsList..."
  419.   put " Cst#:ChronItem# in queue order:"
  420.   repeat with k = 1 to 4
  421.     set Mycstnum to getAt(iHopTxtList, k)
  422.     put Mycstnum && getaProp(iHopItemsList, Mycstnum)
  423.   end repeat
  424. end
  425.  
  426. on mScrollBarCreditScroll me, pScrollUpDist
  427.   set the locV of sprite 3 to 40 - (pScrollUpDist * gScrollIncrK)
  428. end
  429.  
  430. on mScrollBarChartScroll me, pScrollUpDist
  431.   global gChartSpriteList
  432.   set x to 40 - (pScrollUpDist * gScrollIncrK)
  433.   repeat with i = 1 to count(gChartSpriteList)
  434.     set the locV of sprite getAt(gChartSpriteList, i) to x
  435.   end repeat
  436. end
  437.  
  438. on mImportScroll me, pScrollUpDist
  439.   set the locV of sprite 4 to 90 - (pScrollUpDist * gScrollIncrK)
  440. end
  441.